@echo off
chcp 65001 >nul

echo ================================
echo 开始启动所有服务...
echo 启动顺序: Eureka Server - API Gateway - Data Access Service - 个人服务模块
echo ================================

rem 启动Eureka Server服务注册中心
echo 正在启动Eureka Server...
start cmd /k "title Eureka Server && cd /d %~dp0PersonalComprehensiveService\eureka-server\target && java -jar eureka-server-1.0.0-SNAPSHOT.jar && exit"

echo 等待Eureka Server初始化...
timeout /t 25 /nobreak >nul

rem 启动API Gateway
echo 正在启动API Gateway...
start cmd /k "title API Gateway && cd /d %~dp0PersonalComprehensiveService\api-gateway\target && java -jar api-gateway-1.0.0-SNAPSHOT.jar && exit"

echo 等待API Gateway初始化...
timeout /t 20 /nobreak >nul

rem 启动Data Access Service
echo 正在启动Data Access Service...
start cmd /k "title Data Access Service && cd /d %~dp0PersonalComprehensiveService\data-access-service\target && java -jar data-access-service-1.0.0-SNAPSHOT.jar && exit"

echo 等待Data Access Service初始化...
timeout /t 20 /nobreak >nul

rem 启动个人文件服务
echo 正在启动Personal File Service...
start cmd /k "title Personal File Service && cd /d %~dp0PersonalComprehensiveService\personal-file-service\target && java -jar personal-file-service-1.0.0-SNAPSHOT.jar && exit"

rem 启动个人电影服务
echo 正在启动Personal Movie Service...
start cmd /k "title Personal Movie Service && cd /d %~dp0PersonalComprehensiveService\personal-movie-service\target && java -jar personal-movie-service-1.0.0-SNAPSHOT.jar && exit"

rem 启动个人笔记服务
echo 正在启动Personal Notes Service...
start cmd /k "title Personal Notes Service && cd /d %~dp0PersonalComprehensiveService\personal-notes-service\target && java -jar personal-notes-service-1.0.0-SNAPSHOT.jar && exit"

rem 启动个人小说服务
echo 正在启动Personal Novel Service...
start cmd /k "title Personal Novel Service && cd /d %~dp0PersonalComprehensiveService\personal-novel-service\target && java -jar personal-novel-service-1.0.0-SNAPSHOT.jar && exit"


echo 启动前端: 前端 Server -内网穿透应用

rem 启动前端应用
echo 正在启动前端应用
start cmd /k "title personUi && cd /d %~dp0PersonalComprehensiveWeb &&pnpm -C .\apps\frontend\ run dev  && exit"

rem 启动前端管理应用
echo 正在启动前端管理应用
start cmd /k "title personUiAdmin && cd /d %~dp0PersonalComprehensiveWeb &&pnpm -C .\apps\backend\ run dev && exit"

echo ================================
echo 所有服务已启动完成！
echo 请不要关闭此窗口，服务运行在独立的命令窗口中
echo 若需停止所有服务，请关闭所有相关命令窗口
echo ================================
pause